import 'dart:convert';

import 'package:sp_util/sp_util.dart';

class QUtils {
  static bool localLike(String article) {
    bool isContain = false;
    List<String> likes = [];
    try {
      var likeStr = SpUtil.getString("likeA") ?? '[]';
      List<dynamic> likeList = jsonDecode(likeStr);
      for (var element in likeList) {
        likes.add(element.toString());
      }
      isContain = likes.contains(article);
    } catch (e) {
      print(e);
    }
    return isContain;
  }

  static String nowTimeStr() {
    return DateTime.now().toLocal().toString().substring(0, 19);
  }

  static String getName() {
    return SpUtil.getString("username") ?? '';
  }

  static String getProfile() {
    return SpUtil.getString("profile") ?? '';
  }
}
